/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-22 09:22:43
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-10-19 10:19:20
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\SampleEnclosure.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { API_LIST } from '../../Api/Api'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure } from '../options'

export const SampleEnclosure = async ({ upDataEvent, data, Permission }) => {
    console.log(Permission)
    let dataList = {
        type: '样品附件信息',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST([data.uuid])['getSampleAttachments'],
        options: [
            Permission.findIndex(v => v.uuid === '3555d7ff-145e-48c1-b0ad-4b1718f9a3b7') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="添加附件"
                    ThrKey="ThrModal"
                    value="SampleEnclosure"
                    data={data}
                />
            ),
        ],
        columns: [
            {
                title: '附件名称',
                dataIndex: 'tableName',
                search: false,
                type: 'hidden',
                render: (_, { attachment }) => <div>{attachment.originalName}</div>,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <SeeEnclosure
                            key="see"
                            data={{
                                className: 'Admin',
                                url: record.attachment.fileUrl,
                            }}
                        />,
                        Permission.findIndex(v => v.uuid === 'd71431a1-0a60-4caf-868c-77c70b3d925d') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delSampleAttachments', title: '删除样品附件' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
